package com.shyroke.daydayzhuanapi.mapper;

import cn.hutool.core.date.DateUtil;
import com.shyroke.daydayzhuanapi.dto.NewsDto;
import com.shyroke.daydayzhuanapi.entity.NewsEntity;
import org.modelmapper.ModelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class NewsMapper {
    @Autowired
    private ModelMapper modelMapper;

    public NewsDto entityToDto(NewsEntity e) {
        NewsDto dto = modelMapper.map(e, NewsDto.class);
        dto.setShowCreateTime(DateUtil.format(e.getDate(),"yyyy-MM-dd HH:mm:ss"));
        return dto;
    }
}
